package javaman.servlet;

import java.io.IOException;

import javaman.gestor.GestorProfesor;
import javaman.modelo.Usuario;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class ProfesorServlet
 */

public class ProfesorServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	GestorProfesor gestorProfesor = new GestorProfesor();

	
    /**
     * Default constructor. 
     */
    public ProfesorServlet() {
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		System.out.println("Entro al Buscar profesor");
		
		String campo = request.getParameter("campo");
		String criterio = request.getParameter("criterio");
		
		String consulta = campo+" like '%"+criterio+"%'";
		
		Usuario[] profesores = gestorProfesor.buscarProfesorPorCampo(consulta);
		
		request.setAttribute("arrListado",profesores);
		
		RequestDispatcher rd = request.getRequestDispatcher("/listadoProfesor.jsp");
		rd.forward(request, response);
		
		
	}

}
